#!/bin/bash

# 功能A
function_a() {
clear
echo
    echo "连接设备"
    mapfile -t device_list < <(termux-usb -l | sed '1d;$d' | sed -E 's/.+"(.+)",?$/\1/g')
n=1
for i in "${device_list[@]}";do
echo "$n. $i"
((n++))
done
read -p "以序列号选择设备: " index
termux-usb -r -e $SHELL -E "${device_list[index-1]}"
echo
bash $0
}

# 功能B
function_b() {
clear
    echo 正在更新
    bash -c "$(curl -L https://gitee.com/tytysky/update/raw/master/Nachoneko/install)"
    echo
    bash $0
}
function_c() {
clear
    echo 成功执行c
    echo
    bash $0
}
# 显示简单菜单
echo "请选择要执行的功能:"
echo "1. 链接设备"
echo "2. 更新插件"
echo "3. 功能c"
echo "输入其他内容退出"
echo -n "请选择 [1-3]: "

# 读取用户输入
read choice

# 根据选择执行功能
case $choice in
    1) function_a ;;
    2) function_b ;;
    3) function_c ;;
    *) echo "退出" ;;
esac